<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/25
 * Time: 15:48
 */

namespace app\admin\controller;

/*
 * 配置管理
 * */
use app\admin\model\ConfigModel;
use think\Request;

class Config extends Base
{

    protected $configModel;

    /*
    * 依赖注入Model
    * */
    public function __construct(ConfigModel $configModel){
        parent::__construct();
        $this->configModel = $configModel;
    }

    /*
     * 邮件配置信息
     * */
    public function config_email(){
        $this->assign("data",$this->configModel->listAll());
        return $this->fetch("config/email_config");
    }

    /*
     * 更新邮件配置信息
     * */
    public function config_email_edit(){
        if(Request::instance()->isPost()){
            $validate=$this->configModel->validate_model();
            if ($validate['code'])
                return $this->configModel->edit();
            else
                return $validate;
        }
        return $this->fetch('config/email_config');
    }

    /*
     * 邮件Test
     * */
    public function test(){
        //email('1727420286@qq.com','家校互动管理系统测试','邮件发送测试');
    }

}